<template>
	<view class="page">
		<view class="header-name">到账账户</view>
		<view class="header-content flex" @click="isPopup = true">
			<image src="@/static/img/zfb.png" v-if="current === 1" mode=""></image>
			<image src="@/static/img/wx.png" v-else mode=""></image>
			<view>{{selectName}}</view>
			<text class="tn-icon-right" style="color: #999999;font-size: 40rpx;"></text>
		</view>
		<view class="card">
			<view class="card-title">提现金额</view>
			<view class="card-price flex">
				<view>￥</view>
				<input type="number" v-model="withmoney">
			</view>
			<view class="card-tips">当前可提现金额{{ money }}，<text style="color: #0E71EB;" @click="withmoney = money">全部提现</text></view>
		</view>
		<view class="btn" @click="submit">确认</view>

		<tn-popup v-model="isPopup" mode="bottom" :maskCloseable="false" :borderRadius="60" closeBtn
			closeIconColor="#222222" :closeIconSize="48" closeBtnPosition="top-left">
			<view class="popup">
				<view class="popup-title center">切换收款账户</view>
				<view class="popup-item" @click="select(2)">
					<view class="flex" style="width: 100%;justify-content: space-between;">
						<view class="flex" style="width: 60%;">
							<image style="width:50rpx;height:50rpx;" src="@/static/img/wx.png" mode=""></image>
							<view style="width:300rpx;">微信</view>
						</view>
						<image src="@/static/img/success.png" v-if="current === 2" class="success" mode=""></image>
					</view>
				</view>
				<view class="popup-item" @click="select(1)">
					<view class="flex" style="width: 100%;justify-content: space-between;">
						<view class="flex" style="width: 60%;">
							<image style="width:50rpx;height:50rpx;" src="@/static/img/zfb.png" mode=""></image>
							<view style="width:300rpx;">支付宝</view>
						</view>
						<image src="@/static/img/success.png" v-if="current === 1" class="success" mode=""></image>
					</view>
				</view>
				<view class="popup-content">
					<input type="text" :placeholder="current == 2 ? '请输入微信真实姓名':'请输入支付宝账号'" v-model="content" />
				</view>
				<view class="btn" style="margin-top: 40rpx;" @click="isPopup = false">确认</view>
			</view>
		</tn-popup>
	</view>
</template>

<script>
	import wxSDK from '../../utils/wxSDK';
	export default {
		data() {
			return {
				isPopup: false,
				current:2,
				selectName: '微信',
				money:0,
				withmoney:'',
				content:''
			};
		},
		onLoad() {
			this.money = uni.getStorageSync('usermsg').money;
		},
		methods: {
			select(type) {
				this.current = type;
				this.selectName = type === 2 ? '微信' :'支付宝'
				this.content = ''
			},
			submit() {
				if(!wxSDK.isWechat()){
					return false
				}
				let sendData = {
					amount:this.withmoney,
					type:this.current,
					content:this.content,   // 支付宝传账号、微信传真实姓名
				};
				if(this.content == ''){
					if(this.selectName == 1){
						this.apifun.toast('请输入支付宝提现账号');
					}else{
						this.apifun.toast('请输入微信真实姓名');
					}
				};
				this.apifun.unirequest('/partner/user/withdraw','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.apifun.toast('提现申请已提交')
						this.apifun.goback();
					}else if(res.code == 10002){
						this.apifun.navigate('/pages/start/fenglogo')
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			accreditfun(code){
				let sendData = {
					code:code
				};
				this.apifun.unirequest('/partner/index/wxScope','post',sendData,(res)=>{
					if(res.code === 1){
						let datas = res.data;
					}else{
						this.apifun.toast(res.msg)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.popup {
		height: 740rpx;
		padding: 40rpx 30rpx;
		box-sizing: border-box;

		.popup-title {
			font-size: 34rpx;
			font-weight: bold;
			margin-bottom:60rpx;
		}

		.popup-item {
			margin-top:20rpx;
			padding-bottom:30rpx;

			image {
				margin-right: 20rpx;
				width: 40rpx;
				height: 40rpx;
			}

			view {
				width: 520rpx;
				font-size: 36rpx;
				font-weight: bold;
			}
		}
		
		.popup-content {
			margin: 28rpx 0 0 60rpx;
			width: 560rpx;
			height: 84rpx;
			border-radius: 10rpx;
			padding: 24rpx 26rpx;
			background: #F7F7F7;
			input{
				font-size: 26rpx;
			}
		}
	}

	.page {
		padding: 0 30rpx;
		box-sizing: border-box;
	}

	.header-name {
		padding-top: 54rpx;
		font-size: 30rpx;
	}

	.header-content {
		margin-top: 48rpx;

		image {
			width: 40rpx;
			height: 40rpx;
			margin-right: 20rpx;
		}

		view {
			font-size: 36rpx;
			font-weight: bold;
			width: 550rpx;
		}
	}

	.card {
		margin-top: 90rpx;
		height: 300rpx;
		border-radius: 50rpx;
		background: #FFFFFF;
		padding: 34rpx 48rpx 30rpx 48rpx;
		box-sizing: border-box;

		.card-title {
			font-size: 30rpx;
		}

		.card-price {
			margin-top: 40rpx;
			padding-bottom: 20rpx;
			border-bottom: 2rpx solid #EBEBEB;

			view {
				font-size: 50rpx;
				font-weight: bold;
			}
			input{
				font-size:40rpx;
			}
		}

		.card-tips {
			margin-top: 24rpx;
			font-size: 24rpx;
			color: #999999;
		}
	}

	.btn {
		width: 600rpx;
		margin-top: 480rpx;
	}
</style>